<?php
require_once('../includes/config.php'); // file de config
include DIR_INCLUDES_FT.'bootstrap.php';
header('Content-type: text/html; charset=utf-8');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt" lang="pt" dir="ltr">
	<head>
		<?require(DIR_FT."header.php");?>
		<script type="text/javascript" src="<?=DIR_LOGS_WS?>historico.js"></script>
		<script type="text/javascript">
			function get_logs(){
				$.ajax({
					type: "POST",
					url: "<?=DIR_LOGS_WS?>historico.serverside.php",
					dataType: "html",
					data: {
						tabela: $('#tabela').val(), codigo: $('#codigo').val(), user: $('#user').val(),
						data_inicio: $('#data_inicio').val(), data_fim: $('#data_fim').val(), accao: $('#accao').val()
					},
					success: function (data, textStatus) {
						$('#logs_div').html(data);
						$('#logs_accordion').accordion('destroy');
						$('#logs_accordion').accordion({header: 'h3',active:1, collapsible: false, autoHeight:false, clearStyle:false});
					}
				});
			}
		</script>
	</head>
	<body>
		<?php require_once(DIR_MENUS_FT."menu.php");?>
		<div id="main_div">
			<div id="logs_accordion">
				<h3><a style="font-family:trebuchet MS;font-size:1.1em;cursor:pointer;"><?=FILTROS_PESQUISA_LOGS?></a></h3>
				<div id="pesquisa_logs">
					<label for="tabela"><?=TABELA?></label>
					<select id="tabela" name="tabela">
						<option value=""><?=SELECT_TABELA?></option>
						<?php
						Doctrine_Manager::getInstance()->setCurrentConnection('logs_connection');
						$tabelas = Doctrine_Query::create()->from("Tabelas")->where("is_monitoring = 1")->fetchArray();
						Doctrine_Manager::getInstance()->setCurrentConnection('base_connection');
						foreach ($tabelas as $tabela) {?>
						<option value="<?=$tabela['id']?>"><?=$tabela['nome']?></option>
						<?}?>
					</select>
					<label for="tabela"><?=ACCAO?></label>
					<select id="accao" name="accao">
						<option value=""><?=SELECT_ACCAO?></option>
						<option value="1"><?=INSERCAO?></option>
						<option value="2"><?=MODIFICACAO?></option>
						<option value="3"><?=REMOCAO?></option>
					</select>
					<label for="codigo"><?=ID?></label>
					<input id="codigo" name="codigo" />
					<label><?=DATA?> Inicio</label><input id="data_inicio" name="data_inicio" />
					<label><?=DATA?> Fim</label><input id="data_fim" name="data_fim" />
					<input class="submit-button" type="submit" onclick="get_logs();" value="<?=PROCURAR?>" />
				</div>
				<h3><a style="font-family:trebuchet MS;font-size:1.1em;cursor:pointer;"><?=LOGS?></a></h3>
				<div id="logs_div">
					<div style="height: 100px;margin-top: 10px;">Não existem resultados para mostrar</div>
				</div>
			</div>
		</div>
		<?require(DIR_FT."footer.php");?>
	</body>
</html>